//
//  CWQViewController.m
//  zhuMuTest
//
//  Created by 陈武琦 on 16/3/24.
//  Copyright © 2016年 陈武琦. All rights reserved.
//

#import "CWQViewController.h"
#import <ZhumuSDK/ZhumuSDK.h>
#import "MainViewController.h"
#import <Zhumu/Zhumu.h>
//#import "AppDelegate.h"
#import <objc/runtime.h>
@interface CWQViewController ()<ZhumuSDKAuthDelegate>
@end

@implementation CWQViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
    [self.view addSubview:btn];
    [btn addTarget:self action:@selector(next) forControlEvents:UIControlEventTouchUpInside];
    btn.backgroundColor = [UIColor redColor];
    // Do any additional setup after loading the view.
}


- (void)next {
    MainViewController *mainController = [[MainViewController alloc] init];
    
    UIViewController *rootVc = [[UIApplication sharedApplication] keyWindow].rootViewController;
    objc_setAssociatedObject(mainController, &rootKey, rootVc, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
    mainController.rootVC = rootVc;
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:mainController];
    
    [navController setNavigationBarHidden:NO];
    [[UIApplication sharedApplication] keyWindow].rootViewController = navController;
//    //1. 设置ZhumuSDK的Root Navigation Controller
    [[ZhumuSDK sharedSDK] setZhumuRootController:navController];
    
    //[self presentViewController:navController animated:YES completion:nil];
    //[self.navigationController pushViewController:mainController animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
